(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        define(['exports'], factory);
    } else if (typeof module === 'object' && module.exports) {
        module.exports = factory(exports);
    } else {
        root.Formater = factory();
    }
}(typeof self !== 'undefined' ? self : this, function () {
    function number(data, size = 2) {
        if (data instanceof Uint8Array) {
            let arr = [];
            for (let byte of data) {
                arr.push(`0x${byte.toString(16).padStart(2, '0')}`);
            }
            return `[${arr.join(', ')}]`;
        }
        if (typeof data === 'number') {
            return `0x${data.toString(16).padStart(size, '0')} = ${data.toString()}`;
        }
    };

    function char(data) {
        if (data instanceof Uint8Array) {
            let arr = [];
            for (let byte of data) {
                arr.push(`'${String.fromCharCode(byte)}'`);
            }
            return `[${arr.join(', ')}]`;
        }
        if (typeof data === 'number') {
            return `'${String.fromCharCode(data)}'`;
        }
        return `'${data}'`;
    }

    function str(data) {
        return data;
    }

    function varint(data) {
        return `0x${data.toString(16).padStart(2, '0')}`;
    }

    function hash(data) {
        let arr = [];
        for (let byte of data) {
            arr.push(`${byte.toString(16).padStart(2, '0')}`);
        }
        return `${arr.join('')}`;
    }
    return {
        number,
        char,
        str,
        varint,
        hash,
    };
}));